coord_cartesian
Setting limits on the coordinate system to zoom the plot and then convert them with ggplotly.
p <- ggplot(mtcars, aes(disp, wt)) + geom_point() + geom_smooth()
plotly::ggplotly(p)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
p <- ggplot(mtcars, aes(disp, wt)) + geom_point() + geom_smooth() p <- p + scale_x_continuous(limits = c(325, 500))
plotly::ggplotly(p)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 24 rows containing non-finite values (stat_smooth).
p <- ggplot(mtcars, aes(disp, wt)) + geom_point() + geom_smooth() p <- p + coord_cartesian(xlim = c(325, 500))
plotly::ggplotly(p)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
p <- ggplot(mtcars, aes(disp, wt)) + geom_point() + geom_smooth() p <- p + coord_cartesian(xlim = c(325, 500), expand = FALSE)
plotly::ggplotly(p)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
p <- ggplot(mtcars, aes(disp, wt)) + geom_point() + geom_smooth() p <- p + coord_cartesian(expand = FALSE)
plotly::ggplotly(p)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
d <- ggplot(diamonds, aes(carat, price)) + stat_bin2d(bins = 25, colour = "white")
plotly::ggplotly(d)
d <- ggplot(diamonds, aes(carat, price)) + stat_bin2d(bins = 25, colour = "white") p <- d + scale_x_continuous(limits = c(0, 1))
plotly::ggplotly(p)
## Warning: Removed 17502 rows containing non-finite values (stat_bin2d).
d <- ggplot(diamonds, aes(carat, price)) + stat_bin2d(bins = 25, colour = "white") p <- d + coord_cartesian(xlim = c(0, 1))
plotly::ggplotly(p)